//
//  ViewController.swift
//  自定义刷新控件
//
//  Created by yang on 2017/10/28.
//  Copyright © 2017年 成品家（北京）网络科技有限公司. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    lazy var refreshControl = MeituanRefreshControl()
    lazy var tableView = UITableView(frame: CGRect(x: 0, y: 64, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height), style: .plain)
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(tableView)
        tableView.addSubview(refreshControl)

        refreshControl.addTarget(self, action: #selector(loadData), for: .valueChanged)
        loadData()
        
        // Do any additional setup after loading the view.
    }
    @objc private func loadData()
    {
        refreshControl.beginRefreshing()

        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 3)
        {
            self.refreshControl.endRefreshing()
        }
    }

}

